草庐IT

Android Studio 找不到 JUnit 包

全部标签

java.lang.AssertionError : Content type not set while junit Spring MVC Controller? 错误

我正在使用JUnit来测试我的SpringMVCController。下面是我的方法,它返回一个index.jsp页面并在屏幕上显示HelloWorld-@RequestMapping(value="index",method=RequestMethod.GET)publicHashMaphandleRequest(){HashMapmodel=newHashMap();Stringname="HelloWorld";model.put("greeting",name);returnmodel;}下面是我对上述方法的JUnit测试:publicclassControllerTest{p

java - 为什么 junit4 没有 Assert.assertArrayEquals() for double[]s?

在Junit4中似乎有Assert.assertArrayEquals()方法用于除double之外的所有原语,例如Assert.assertArrayEquals(int[]expected,int[]actual)和Assert.assertArrayEquals(char[]expected,char[]actual)但不是Assert.assertArrayEquals(double[]expected,double[]actual,doubleeps)或Assert.assertArrayEquals(double[]expected,double[]actual,doubl

java - JUnit assertEquals 更改字符串

我有一个JUnit测试如下:@TestpublicvoidtestToDatabaseString(){DateConvertorconvertor=newDateConvertor();Datedate=convertor.convert("20/07/1984:00:00:00:00");StringconvertedDate=convertor.toDatabaseString(date);assertEquals("to_date('20/07/1984:00:00:00:00','DD/MM/YYYYHH24:MI:SS')",convertedDate);}测试失败说明:o

java - 在 JUnit 4 的@Before 中获取当前正在执行的 @Test 方法

我想在@Before中获取当前正在执行的测试方法,以便我可以获得应用于当前正在执行的方法的注释。publicclassTestCaseExample{@BeforepublicvoidsetUp(){//getcurrentmethodhere.}@Test@MyAnnotation("id")publicvoidsomeTest{//code}} 最佳答案 尝试TestName规则publicclassTestCaseExample{@RulepublicTestNametestName=newTestName();@Before

java - 找不到符号 - T 类

我有这个功能;publicstaticT[]addToArray(Titem,T...items){T[]array;intarray_size=1;if(items!=null){array_size=items.length+1;}array=java.util.Arrays.copyOf(items,array_size);array[array_size-1]=item;returnarray;}我收到此错误cannotfindsymbolsymbol:classT。这个想法是使这个方法通用。我从未使用过泛型,所以我猜我错过了一些引用资料? 最佳答案

eclipse - 在 Windows 7 64 位机器上找不到启动 Eclipse 3.6.1 的 Java 虚拟机

我知道一些C#并且我使用VisualStudio2008,但现在我正在尝试帮助我的儿子使用一些基本的Java程序。我已经安装了我认为正确版本的Eclipse:eclipse-SDK-3.6.1-win32-x86_64我有一个小的“helloworld”入门.java文件,我想运行和玩,但我什至无法在这台机器上启动。我立即收到此消息:“Java运行时环境(JRE)或Java开发工具包(JDK)必须可用才能运行Eclipse。在搜索以下位置后未找到Java虚拟机:C:\Users\john\Documents\eclipse-SDK-3.6.1-win32-x86_64\eclipse\

java - 在 eclipse indigo 中找不到 Window builder pro

我读到EclipseIndigo已安装WindowBuilderPro插件,但我看不到它在哪里。文件/新建/项目没有给我选择WindowBuilderPro的选项。如何找到它? 最佳答案 您需要将此更新站点添加到Eclipse。http://download.eclipse.org/windowbuilder/WB/release/R201106211200/3.7/我在这个页面上找到了http://eclipse.org/windowbuilder/download.php 关于jav

java - Eclipse 在 Ubuntu 上找不到 Java

Java已正确安装在我的Ubuntu12.04中,并且在.bashrc文件中设置了PATH变量。java-version命令给出了预期的输出。但是当我尝试启动Eclipse时,它​​会提示找不到JDK。 最佳答案 您可能需要编辑您的eclipse.ini文件并在其中提及路径。阅读this了解更多详情。编辑:-vm/opt/sun-jdk-1.6.0.02/bin/java这就是您的vm参数在.ini文件中的样子。如果没有,请更改它。不过要小心路径。一般Java安装在/opt中,但请在您的系统上检查一次。另外,看看this还有问题。

java - 为什么 Java 找不到我的构造函数?

好吧,也许这是一个愚蠢的问题,但我无法解决这个问题。在我的ServiceBrowser类中,我有这一行:ServiceResolverserviceResolver=newServiceResolver(ifIndex,serviceName,regType,domain);编译器会提示。它说:cannotfindsymbolsymbol:constructorServiceResolver(int,java.lang.String,java.lang.String,java.lang.String)这很奇怪,因为我在ServiceResolver中确实有一个构造函数:publicvo

java - FileNotFoundException(系统找不到指定的路径)

我得到这个异常:java.io.FileNotFoundException:C:\...\filename.xml(Thesystemcannotfindthepathspecified)使用此代码:FileWriterfileWriter=newFileWriter(newFile(path+date+time"filename.xml"));BufferedWriterwriter=newBufferedWriter(fileWriter);writer.write("data");路径存在,但需要创建“日期”和“时间”的目录。应用程序对该目录具有完全权限。有什么想法吗?